package com.mkr.service.impl;

import com.mkr.dao.BookDao;
import com.mkr.dao.impl.BookDaoImpl;
import com.mkr.entity.Book;
import com.mkr.entity.Page;
import com.mkr.service.BookService;

import java.util.List;

/**
 * @author mkr
 * @version V1.0
 * @Project BookApp
 * @Package com.mkr.service.impl
 * @Description:
 * @Date 2022/5/14 15:23
 */
public class BookServiceImpl implements BookService {

    private BookDao bookDao = new BookDaoImpl();

    @Override
    public List<Book> getAll() {
        return  bookDao.selectAll();
    }

    @Override
    public boolean addOne(Book book) {
        return bookDao.addOne(book)>0;
    }

    @Override
    public boolean deleteOne(String bookId) {
        return bookDao.deleteOne(bookId)>0;
    }

    @Override
    public Book selectOne(String bookId) {
        return bookDao.selectOne(bookId);
    }

    @Override
    public boolean updateOne(Book book) {
        return bookDao.updateOne(book)>0;
    }

    @Override
    public List<Book> findAllPage(Page page) {
        List<Book> list = bookDao.selectAllByPage(page);
        return list;
    }

    @Override
    public int findAllPageCount() {
        int count = bookDao.selectAllByPageCount();
        return count;
    }
}
